﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Serviio.API
{
    public class ServiioOnlineRepository
    {
        public string Id { get; private set; }
        public string RepositoryName { get; set; }
        public string RepositoryType { get; set; }
        public string ContentURL { get; set; }
        public string FileTypeString { get; private set; }
        public string ThumbnailURL { get; set; }
        public bool Enabled { get; set; }
        
        public enum FileTypes
        {
            Image = 0,
            Audio = 1,
            Video = 2,
            Unknown
        }

        private string[] fileTypeStrings =
        {
            "IMAGE",
            "AUDIO",
            "VIDEO"
        };

        public FileTypes FileType
        {
            get
            {
                for (int i = 0; i < fileTypeStrings.Length; i++)
                    if (fileTypeStrings[i].Equals(FileTypeString))
                        return (FileTypes)i;

                return FileTypes.Unknown;
            }
            set
            {
                FileTypeString = fileTypeStrings[(int)value];
            }
        }


        public ServiioOnlineRepository(string repositoryName, string repositoryType, string contentURL, FileTypes fileType, string thumbnailURL = null, bool enabled = true)
        {
            Id = null;
            RepositoryName = repositoryName;
            RepositoryType = repositoryType;
            ContentURL = contentURL;
            FileType = fileType;
            ThumbnailURL = thumbnailURL;
            Enabled = enabled;
        }

        public ServiioOnlineRepository(string id, string repositoryName, string repositoryType, string contentURL, FileTypes fileType, string thumbnailURL = null, bool enabled = true)
        {
            Id = id;
            RepositoryName = repositoryName;
            RepositoryType = repositoryType;
            ContentURL = contentURL;
            FileType = fileType;
            ThumbnailURL = thumbnailURL;
            Enabled = enabled;
        }
    }
}
